= render_modal(title: t('.title'), size: 'xl') do
  .row
    .col-md-6
      - unless @user.confirmed?
        .card.mb-3
          .card-header.card-border
            h3.card-title = t('admin.users.edit.active_link')
            .card-tools
              = link_to t('admin.users.edit.resend'), resend_confirmation_admin_user_path(@user), \
                class: 'btn btn-primary', data: { turbo_method: :put, action: 'modal#close' }
          .card-body
            .d-flex data-controller="clipboard-center"
              ruby:
                confirmation_url = confirmation_url(@user, confirmation_token: @user.confirmation_token)
              input.flex-fill.rounded-start.border-0.w-100.p-2.ps-3 value="#{confirmation_url}" readonly="true" data-clipboard-center-target="source"
              button.btn.btn-primary.rounded-0.rounded-end[
                data-action="clipboard-center#copy"
                data-clipboard-text="#{confirmation_url}"
              ]
                i.fa-regular.fa-clipboard
            small.form-text.text-muted
              = raw t('admin.users.edit.active_link_tip', label: t('admin.users.edit.resend'), link: resend_confirmation_admin_user_path(@user))

      .card.mb-3
        .card-header.card-border
          h3.card-title = t('admin.users.edit.profile')
        == render 'form', user: @user

    .col-md-6
      - if @user.collaborators.present?
        .card.mb-3
          .card-header.card-border
            h3.card-title = t('admin.users.edit.collaborators')
          .card-body.p-0
            table.table.table-bottom-borderless
              - @user.collaborators.each do |collaborator|
                tr
                  td = link_to collaborator.app.name, app_path(collaborator.app)
                  td
                    - if collaborator.owner
                      = link_to t('activerecord.attributes.collaborator.owner'), new_owner_app_path(collaborator.app)
                    - else
                      = link_to Setting.builtin_roles[collaborator.role.to_sym], edit_app_collaborator_path(collaborator.app, collaborator.user_id)

      .card.mb-3
        .card-header.card-border
          h3.card-title = t('admin.users.edit.api')
        .card-body
          .d-flex.flex-column
            label.pb-2 = t('admin.users.edit.token')
            .d-flex data-controller="clipboard-center"
              input.flex-fill.rounded-start.border-0.p-2.ps-3 type="text" readonly=true value="#{@user.token}" data-clipboard-center-target="source"
              button.btn.btn-primary.rounded-0.rounded-end[
                data-action="clipboard-center#copy"
                data-clipboard-text="#{@user.token}"
              ]
                i.fa-regular.fa-clipboard

      .card.mb-3
        .card-body
          .float-end
            - if default_admin_in_demo_mode?(current_user)
              button.btn.btn-danger.disabled
                = t('admin.users.edit.destroy_user')
            - else
              = link_to t('admin.users.edit.destroy_user'), admin_user_path(@user), class: 'btn btn-danger', \
                        data: { turbo_method: :delete, action: 'modal#close', turbo_confirm: t('admin.users.index.destroy_user_confirm', user: @user.username) }
          div
            - if @user.access_locked?
              - if default_admin_in_demo_mode?(current_user)
                button.btn.btn-primary.disabled
                  = t('admin.users.edit.unlock_user')
              - else
                = link_to t('admin.users.edit.unlock_user'), unlock_admin_user_path(@user), class: 'btn btn-primary', data: { turbo_method: :delete, action: 'modal#close' }
            - else
              - if default_admin_in_demo_mode?(current_user)
                button.btn.btn-warning.disabled
                  = t('admin.users.edit.lock_user')
              - else
                = link_to t('admin.users.edit.lock_user'), lock_admin_user_path(@user), class: 'btn btn-warning', data: { turbo_method: :put, action: 'modal#close' }
